<?php
/**
 * @author Zwc
 * Created On 2021/5/3 16:06
 */

namespace app\auth\service;


use app\common\models\AreaModel;

class AreaService extends BaseService
{
    protected $model;
    public function __construct()
    {
        $this->model = new AreaModel();
        parent::__construct();
    }


    public function getData($params) {
        $condition = self::getCondition($params);
        $data = $this->model->where($condition)->order('code asc')->select();
        return $data;
    }

    /**
     * 获取
     * @param $params
     */
    private function getCondition($params) {
        $condition = [];
        if(isset($params['pcode']) && $params['pcode']) {
            $condition[] = ['pcode','=',$params['pcode']];
        }else {
            $condition[] = ['pcode','=',0];
        }
        return $condition;
    }

}